package com.yu.footballpromotionliveadmin.controller;

import com.yu.footballpromotionliveadmin.dto.DTO;
import com.yu.footballpromotionliveadmin.page.PageInfo;
import com.yu.footballpromotionliveadmin.pojo.ActivityType;
import com.yu.footballpromotionliveadmin.service.ActivityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
public class ActivityTypeController {


    @Autowired
    ActivityTypeService activityTypeService;

    @GetMapping("/activityType")
    public DTO<ActivityType> getAllLiveAdmin() throws Exception {

        return activityTypeService.getAllActivityTypes();
    }

    @GetMapping("/getactivityType/{actno}")
    public DTO<ActivityType> getLiveAdminById(@PathVariable("actno") String actno) throws Exception {

        return activityTypeService.getActivityTypeById(actno);
    }


    @PostMapping("/activityType")
    public DTO<ActivityType> getLiveAdminById(@RequestBody  ActivityType activityType) throws Exception {

        return activityTypeService.addActivityType(activityType);
    }


    @PatchMapping("/activityType")
    public DTO<ActivityType> updateLiveAdmin(@RequestBody ActivityType activityType) throws Exception {

        return activityTypeService.updateActivityType(activityType);
    }
    
    @GetMapping("/getactivityTypeByPage")
    public DTO<ActivityType> ByPage(PageInfo pageInfo) throws Exception {

        return activityTypeService.getActivityTypesByPage(pageInfo);
    }

    @DeleteMapping("/activityType/{actno}")
    public DTO<ActivityType> deleteByKey(@PathVariable("actno") String actno) throws Exception {

        return activityTypeService.deleteActivityType(actno);
    }
}
